package com.smart.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smart.dao.BaseDao;
import com.smart.dao.OnlineCountDao;
import com.smart.model.OnlineCount;
import com.smart.model.OnlineCountCond;

/**
 * 
 * @author Sunxin
 *
 */
 
@Service
public class OnlineCountServiceImpl extends BaseEntityService<OnlineCount, OnlineCountCond, Long> implements OnlineCountService{
	
	private static int ONLINE_COUNT = 0;
	
	@Autowired
	private OnlineCountDao dao;
	
	@Override
	protected BaseDao<OnlineCount, OnlineCountCond, Long> getDao() {
		return dao;
	}
	
	public synchronized void setCurrentOnlineCount(int count) {
		ONLINE_COUNT = count;
	}

	@Override
	public void saveCurrentOnlineCount() {
		OnlineCount record = new OnlineCount();
		record.setCount(ONLINE_COUNT);
		dao.save(record);
		
	}
	
	
}
